/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package question2;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 *
 * @author Avuyile
 */
public class StudentMain {

 public static void main(String[] args) {
        
       Student avu = new Student("Avu", "Malotana", 10, "0733960778"); 
       Student tera = new Student("Tera", "Dyosiba", 11, "0610167543"); 
       Student loid = new Student("Lonwabo", "Khanzi", 12, "0823696250"); 
       Student msija = new Student("Msindisi", "Khanzi", 13, "0215698741"); 
       Student tembie = new Student("Thembie", "Rasmeni", 15, "0785825140"); 
       Student qaqa = new Student("Qaqamba", "Rasmeni", 16, "02145698523"); 
       Student trev = new Student("Trevor", "Watson", 17, "0836547892");
       Student natalie = new Student("Natalie", "Manicum", 18, "0847965231");
       Student sally = new Student("Sally", "Mckenzie", 19, "0321456258");
       Student johan = new Student("Johan", "Ehlres", 20, "05632482332");
       
       Student avuCopy = new Student("Avu", "Malotana", 10, "0733960778"); 
       Student teraCopy = new Student("Tera", "Dyosiba", 11, "0610167543"); 
       Student loidCopy = new Student("Lonwabo", "Khanzi", 12, "0823696250");
       Student msijaCopy = new Student("Msindisi", "Khanzi", 13, "0215698741"); 
       Student tembieCopy = new Student("Thembie", "Rasmeni", 15, "0785825140");
       Student qaqaCopy = new Student("Qaqa", "Rasmeni", 15, "0785825140"); 
       Student trevCopy = new Student("Trevor", "Watson", 17, "0836547892"); 
       Student natalieCopy = new Student("Natalie", "Manicum", 18, "0847965231"); 
       Student sallyCopy = new Student("Sally", "Mckenzie", 19, "0321456258"); 
       Student johanCopy = new Student("Johan", "Ehlres", 20, "0563248332"); 
                     
       List<Student> list = new ArrayList();
       
       list.add(avu);
       list.add(avuCopy);
       list.add(tera);
       list.add(teraCopy);
       list.add(loid);
       list.add(loidCopy);
       list.add(msija);
       list.add(msijaCopy);
       list.add(tembie);
       list.add(tembieCopy);
       list.add(qaqa);
       list.add(qaqaCopy);
       list.add(trev);
       list.add(trevCopy);
       list.add(natalie);
       list.add(natalieCopy);
       list.add(sally);
       list.add(sallyCopy);
       list.add(johan);
       list.add(johanCopy);
       
       nonDuplicates(list);
       addressBook(list);
       
    }
    
    public static void nonDuplicates(Collection<Student> list){
       Set<Student> stud = new HashSet(list);
       System.out.printf("Non-Duplicates: %s", stud);
    }
    
    public static void addressBook(Collection<Student> list){
      Scanner input = new Scanner(System.in);  
      
      HashMap map = new HashMap();
        map.put("Avu", "0733960778");
        map.put("Tera", "0610167543");
        map.put("Lonwabo", "0823696250");
        map.put("Msindisi", "0215698741");
        map.put("Thembie", "0785825140");
        map.put("Trevor", "0836547892");
        map.put("Natalie", "0847965231");
        map.put("Sally", "0321456258");
        map.put("Johan", "0563248332");
        map.put("Qaqa", "0658741216");

        Set set = map.entrySet();

        Iterator iter = set.iterator();

        while(iter.hasNext()) {
           Map.Entry check = (Map.Entry)iter.next();
           System.out.print(check.getKey() + ": ");
           System.out.println(check.getValue());
        }

      System.out.println();
      
      System.out.println("Please enter name: ");
      String number = input.nextLine();
      
      map.get(number);
      
      if(number != null){
          System.out.println("The student's CellNumber : " + map.get(number));
      }else{
          System.out.println("Oops, the number cant be found!");
      }
    }    
}
